package ssi.tools;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class FavouritesChecking {
		public static boolean IfFavourite(String animalID, int userID){
			boolean iffavourite = false;
			try{
				Connection connection = new Connector().getConnection();
				Statement statement = connection.createStatement();
				String query = "SELECT COUNT(*) FROM `favourites` WHERE `userId`='"+userID+"' AND `animalID`='"+animalID+"'";
		    	ResultSet rs = statement.executeQuery(query);
		    	rs.next();
		    	if(rs.getInt("COUNT(*)")!=0){
		    		iffavourite = true;
		    	}
			} catch (Exception e){
				e.printStackTrace();
			}
			return iffavourite;
		}
}